package com.huabo.system.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.hbfk.util.JsonBean;
import com.huabo.system.service.TblAttachmentService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@RestController
@RequestMapping("/filePreview")
@Api(value="FilePreviewController",tags={"文件预览Controller"})
public class FilePreviewController {
	
	@Resource
	private TblAttachmentService tblAttachmentService;
	
	@RequestMapping(value = "/getPrivewAttInfo", produces = "application/json; charset=utf-8", method = {RequestMethod.GET})
	@ApiOperation("获取预览附件信息")
    public JsonBean getPrivewAttInfo(HttpServletRequest reques,
    	 @ApiParam(name="token",value="登录用户token",required=true) @RequestHeader("token")String token,
   		 @ApiParam(name="attId",value="附件Id",required=true) @RequestParam(value = "attId", required = true) Integer attId,
   		 @ApiParam(name="attType",value="附件类型 ，1是签署文件，2是正常上传文件",required=true) @RequestParam(value = "attType", required = true) Integer attType) throws Exception {
		JsonBean jsonBean = null;
		try {
			jsonBean =  this.tblAttachmentService.getPrivewAttInfo(token, attId, attType);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return jsonBean;
    }
}
